<div class="form">

    <?php

    /**
     * @var $form CActiveForm
     */
    $form = $this->beginWidget('CActiveForm', array(
        'id' => 'classtime-form',
        'enableAjaxValidation' => false,
    )); ?>

    <?php //echo $form->errorSummary($model); ?>

    <div class="row">
        <?php echo $form->labelEx($model, 'day'); ?>
        <?php echo $form->listBox($model, 'day', array(2 => 'Thứ 2', 3 => 'Thứ 3', 4 => 'Thứ 4', 5 => 'Thứ 5', 6 => 'Thứ 6', 7 => 'Thứ 7', 8 => 'CN'), array('size' => 1)); ?>
        <?php echo $form->error($model, 'day'); ?>
    </div>

    <div class="row">
        <?php echo $form->labelEx($model, 'start_time'); ?>
        <?php echo $form->textField($model, 'start_time'); ?>
        <?php echo $form->error($model, 'start_time'); ?>
    </div>

    <div class="row">
        <?php echo $form->labelEx($model, 'end_time'); ?>
        <?php echo $form->textField($model, 'end_time'); ?>
        <?php echo $form->error($model, 'end_time'); ?>
    </div>

    <div class="row buttons">
        <?php
        if ($model->isNewRecord) {
            echo CHtml::ajaxSubmitButton('Thêm', $this->createUrl('create'), array('success' => 'js:function(data){
            var tday = "";
            if(data.day == "8"){
                tday = "Chủ nhật";
            }else{ tday = "Thứ "+data.day;}
            $("#lstime").find("ul").append("<li>"+tday+", từ "+data.start_time+" đến "+data.end_time+"</li>");
            $("#jobDialog").dialog(close);
            var remove = function () {
                    $(this).remove();
                };

                $("#dxt-mask").fadeOut(remove);
                $("#dxt-box").fadeOut(remove);

		}', 'cache' => false, 'beforeSend' => 'function(){$(\'body\').undelegate(\'#tkbsubmit\', \'click\');}',), array('id' => 'tkbsubmit'));
        } else {
            echo CHtml::ajaxSubmitButton('Sửa',$this->createUrl('update',array('id'=>$model->id)),array('success'=>'js:function(data){
            if(data.success==1){
                $(".time_"+data.id).find("span").html(data.rstrtime);
                var remove = function () {
                    $(this).remove();
                };

                $("#dxt-mask").fadeOut(remove);
                $("#dxt-box").fadeOut(remove);
            }

		}','cache'=>false,'beforeSend'=>'function(){$(\'body\').undelegate(\'#tkbsubmit\', \'click\');}',),array('id'=>'tkbsubmit'));
        }

        ?>
    </div>

    <?php $this->endWidget(); ?>
    <script type="text/javascript">
        $(function () {
            $('#Classtime_start_time').timepicker({});
            $('#Classtime_end_time').timepicker({});
        });
    </script>
</div><!-- form -->